/*
 *    Copyright (c) 2018-2025, xinke All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: xinke
 */
import {getDetails} from '@/api/admin/user'


var validateUsername = (rule, value, callback) => {
  getDetails(value).then(response => {
    if (window.boxType === 'edit') callback()
    const result = response.data.data
    if (result !== null) {
      callback(new Error('编码重复'))
    } else {
      callback()
    }
  })
}
/*XBX新增编码重复校验*/
/*var validateCode = (rule, value, callback) => {
  getCodeDetails(value).then(response => {
    if (window.boxType === 'edit') callback()
    const result = response.data.data
    if (result !== null) {
      callback(new Error('编码重复'))
    } else {
      callback()
    }
  })
}*/
export const tableOption = {
  border: true,
  index: true,
  indexLabel: '序号',
  stripe: true,
  menuAlign: 'center',
  searchMenuSpan:6,
  editBtn: false,
  delBtn: false,
  align: 'center',
  labelWidth: 120,
  addBtn: false,
  column: [{
    fixed: true,
    label: 'id',
    prop: 'userId',
    span: 12,
    hide: true,
    editDisplay: false,
    editDisabled: true,
    addDisplay: false,
  }, {
    fixed: true,
    label: '用户名',
    prop: 'username',
    editDisabled: true,
    slot: true,
    search: true,
    span: 12,
    rules: [{
      required: true,
      message: '请输入用户名'
    },
      {
        min: 3,
        max: 20,
        message: '长度在 3 到 20 个字符',
        trigger: 'blur'
      },
      {validator: validateUsername, trigger: 'blur'}
    ]
  }, {
    fixed: true,
    label: '编码',
    prop: 'code',
    hide: true,
    slot: true,
    span: 12,
    rules: [{
      required: true,
      message: '请输入编码'
    },
      {
        min: 3,
        max: 20,
        message: '长度在 3 到 20 个字符',
        trigger: 'blur'
      },
      /*{validator: validateCode, trigger: 'blur'}*/
    ]
  },
    {
    label: '密码',
    prop: 'password',
    type: 'password',
    value: '',
    hide: true,
    //editDisplay: false,
    span: 12,
    rules: [{
      min: 6,
      max: 20,
      message: '长度在 6 到 20 个字符',
      trigger: 'blur'
    }]
  }, {
    /*label: '所属部门',*/
    label: '所属公司',
    prop: 'deptId',
    formslot: true,
    slot: true,
    span: 12,
    hide: true,
    dataType:"number",
    rules: [{
      required: true,
      message: '请选择公司',
      trigger: 'change'
    }]
  }, {
    label: '手机号',
    prop: 'phone',
    type: 'tel',
    search: true,
    value: '',
    span: 12,
    rules: [{
      min: 11,
      max: 11,
      message: '长度在 11 个字符',
      trigger: 'blur'
    }]
  }, {
    label: '角色',
    prop: 'role',
    formslot: true,
    slot: true,
    overHidden: true,
    span: 12,
    rules: [{
      required: true,
      message: '请选择角色',
      trigger: 'blur'
    }]
  },  {
      label: '曾用名',
      prop: 'usedname',
      hide: true,
      span: 12
    },  {
      label: '昵称',
      prop: 'nickname',
      hide: true,
      span: 12
    },  {
      label: '证件号',
      prop: 'id',
      hide: true,
      span: 12
    },  {
      label: '参加工作日期',
      prop: 'joinworkdate',
      hide: true,
      type: 'datetime',
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      span: 12
    },  {
      label: '出生日期',
      prop: 'birthdate',
      hide: true,
      type: 'datetime',
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      span: 12
    },  {
      label: '家庭地址',
      prop: 'addr',
      hide: true,
      span: 12
    },  {
      label: '家庭电话',
      prop: 'homephone',
      hide: true,
      span: 12
    },  {
      label: '电子邮箱',
      prop: 'email',
      hide: true,
      span: 12
    },  {
      label: '所属组织id',
      prop: 'pk_org',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '创建时间',
      prop: 'creationtime',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      type: 'datetime',
      format: 'yyyy-MM-dd HH:mm',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      span: 12
    },  {
      label: '修改时间',
      prop: 'modifiedtime',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      type: 'datetime',
      format: 'yyyy-MM-dd HH:mm',
      valueFormat: 'yyyy-MM-dd HH:mm:ss',
      span: 12
    },  {
      label: '自定义项1',
      prop: 'def1',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项2',
      prop: 'def2',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项3',
      prop: 'def3',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项4',
      prop: 'def4',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项5',
      prop: 'def5',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项6',
      prop: 'def6',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项7',
      prop: 'def7',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项8',
      prop: 'def8',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项9',
      prop: 'def9',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项10',
      prop: 'def10',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项11',
      prop: 'def11',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项12',
      prop: 'def12',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项13',
      prop: 'def13',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项14',
      prop: 'def14',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项15',
      prop: 'def15',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项16',
      prop: 'def16',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项17',
      prop: 'def17',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项18',
      prop: 'def18',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项1',
      prop: 'def19',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },  {
      label: '自定义项20',
      prop: 'def20',
      hide: true,
      editDisplay: false,
      addDisplay: false,
      span: 12
    },{
      label: '状态',
      prop: 'lockFlag',
      type: 'radio',
      slot: true,
      border:true,
      span: 12,
      rules: [{
        required: true,
        message: '请选择状态',
        trigger: 'blur'
      }],
      dicData: [{
        label: '有效',
        value: '0'
      }, {
        label: '锁定',
        value: '9'
      }]
    },{
      label: '性别',
      prop: 'sex',
      type: 'radio',
      slot: true,
      border:true,
      span: 12,
      rules: [{
        required: true,
        message: '请选择性别',
        trigger: 'blur'
      }],
      dicData: [{
        label: '男',
        value: '0'
      }, {
        label: '女',
        value: '1'
      }]
    },  {
    width: 180,
    label: '创建时间',
    prop: 'createTime',
    type: 'datetime',
    format: 'yyyy-MM-dd HH:mm',
    valueFormat: 'yyyy-MM-dd HH:mm:ss',
    editDisabled: true,
    addDisplay: false,
    span: 12
  }]
}
